package com.atguigu.day03;

import java.util.HashMap;

public class test {
    public static void main(String[] args) throws CloneNotSupportedException {

        HashMap<Object, Object> map = new HashMap<>();
        User user1 = new User(1,"aaa");
        User user2 = new User(1,"aaa");
        User user3 = (User) user1.clone();

        map.put(user1.hashCode(),"111");
        System.out.println(map.get(user1.hashCode()));
        System.out.println(map.get(user2.hashCode()));
        System.out.println((user2.hashCode()));
        System.out.println((user3.hashCode()));
        System.out.println(map.get(user3.hashCode()));

    }


    public static class User  {
        private int age;

        @Override
        public String toString() {
            return "User{" +
                    "age=" + age +
                    ", count='" + count + '\'' +
                    '}';
        }

        @Override
        protected Object clone() throws CloneNotSupportedException {
            return this;
        }

        private String count;

        public User(int age, String count) {
            this.age = age;
            this.count = count;
        }
    }
}
